package spark.math;

public class Geometry {
	private Geometry() {
	}

	public static final float PI = (float) Math.PI;
	public static final float PI_BY_180 = (float) Math.PI / 180.0f;
	public static final float FLOAT_COMPARE_EPSILON = 0.00001f;

	public static float cos(float aFloat) {
		return (float) Math.cos(aFloat);
	}

	public static float tan(float aFloat) {
		return (float) Math.tan(aFloat);
	}

	public static float atan(float aFloat) {
		return (float) Math.atan(aFloat);
	}

	public static float atan2(float y, float x) {
		return (float) Math.atan2(y, x);
	}

	public static float acos(float aFloat) {
		return (float) Math.acos(aFloat);
	}

	public static float sin(float aFloat) {
		return (float) Math.sin(aFloat);
	}

	public static float asin(float aFloat) {
		return (float) Math.asin(aFloat);
	}

	public static float cot(float aFloat) {
		return 1.0f / (float) Math.tan(aFloat);
	}

	public static float degreeToRadian(float aDegree) {
		return aDegree * Geometry.PI_BY_180;
	}

	public static float radianToDegree(float aRadian) {
		return aRadian / Geometry.PI_BY_180;
	}

	public static boolean isIntegerPowerOfTwo(int integer) {
		return (((integer & (integer - 1)) == 0) && (integer != 0));
	}

	public static boolean equals(float a, float b, float epsilon) {
		return Math.abs(a - b) < epsilon;
	}

	public static boolean equals(float a, float b) {
		return equals(a, b, FLOAT_COMPARE_EPSILON);
	}

	public static boolean equals(Vector3 a, Vector3 b, float epsilon) {
		return Math.abs(a.x - b.x) < epsilon &&
		       Math.abs(a.y - b.y) < epsilon &&
		       Math.abs(a.z - b.z) < epsilon;
	}

	public static boolean equals(Vector3 a, Vector3 b) {
		return equals(a, b, FLOAT_COMPARE_EPSILON);
	}

	public static boolean equals(Vector2 a, Vector2 b, float epsilon) {
		return Math.abs(a.x - b.x) < epsilon &&
		       Math.abs(a.y - b.y) < epsilon;
	}

	public static boolean equals(Vector2 a, Vector2 b) {
		return equals(a, b, FLOAT_COMPARE_EPSILON);
	}
}
